$(".information_btn1").click(function() {
	history.back();
});
$(function() {
	var geolocation = new BMap.Geolocation();
	geolocation.getCurrentPosition(function(r) {
		var gps_w = r.point.lat;
		var gps_j = r.point.lng;
		console.log(gps_w);
		console.log(gps_j);
		$(".submit_final").click(function() {
			var name = $("#name").val();
			if(name == "") {
				layer.msg("姓名不能为空");
				return false;
			}
			if(gps_j == '' && gps_w == '') {
				gps_j = 0;
				gps_w = 0;
			}
			var idcard = $("#idcard").val();
			if(idcard == "") {
				layer.msg("身份证不能为空");
				return false;
			} else if(!/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/i.test(idcard)) {
				layer.msg("请填写合法的身份证号");
				return false;
			}
			var teachcard = $("#teachcard").val();
			if(teachcard == "") {
				layer.msg("教练证号不能为空");
				return false;
			}
			var token = localStorage.phone;
			if(!$('#drive_argument').prop('checked')) {
				layer.msg("请先阅读i驾车教练注册协议");
				return false;
			}
			$.ajax({
				url: "https://newapp.icandrive.cn/api/applyTeacher.php",
				data: {
					token: token,
					name: name,
					ID_number: idcard,
					teacher_number: teachcard,
					gps_j: gps_j,
					gps_w: gps_w
				},
				dataType: 'json',
				type: 'post',
				success: function(data) {
					if(data.status == 402) {
						layer.msg("认证系统服务关闭");
					}
					if(data.status == 403) {
						layer.msg("身份信息不匹配");
					}
					if(data.status == 200) {
						layer.msg("申请成功，请等待审核");
						setInterval(function() {
							window.location.href = "../my/me.html";
						}, 2000);
					}
					if(data.status == 500) {
						layer.msg("请重新登陆");

						setInterval(function() {
							window.location.href = "../login/log_in.html";
						}, 2000)
					}
					if(data.status == 450) {
						layer.msg("您已申请过，请等待审核");
					}
					if(data.status == 400) {
						layer.msg(data.msg);
					}
				},
				error: function() {
					layer.msg('系统繁忙', function() {
						history.go(0)
					}, 1000);
				}
			});
		});
	});

});

/*监听手机返回按键*/
return_keybord();
